import scrapy
from shopSpider.items import ShopListItem
import json


class ShoplistSpider(scrapy.Spider):
    name = "shopList"
    allowed_domains = ["api-gw.onebound.cn"]
    keywords = '高露洁'
    secret = '23883da6' 
    key = 't9911312388'   
    start_urls = ["https://api-gw.onebound.cn/taobao/item_search_seller/?key={}&&q={}&page=1&sort=&&lang=zh-CN&secret={}&size=20".format(key,keywords,secret)]

    def parse(self, response):
        data = json.loads(response.text)
        for shopItem in data['items']['item']:
            item = ShopListItem()
            item['title'] = shopItem['title']
            item['user_num_id'] = shopItem['user_num_id']
            item['zhuy'] = shopItem['zhuy']
            item['nick'] = shopItem['nick']
            item['shop_Id'] = shopItem['shop_Id']
            item['type'] = shopItem['type']
            item['pic_url']= shopItem['pic_url']
            yield item
